package com.qk.management.controller;

import com.qk.common.api.LogisticsApi;
import com.qk.common.enums.BizEnum;
import com.qk.common.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author:gzc
 * @Date: 2025/10/09 16:41
 * @Description:
 */
@RestController
public class LogisticsController {

    @Autowired
    private LogisticsApi logisticsApi;
    @GetMapping("/logistics")
    public Result queryLogistics(@RequestParam String number,
                                 @RequestParam(required = false) String companyCode,
                                 @RequestParam(required = false) String mobile) throws Exception {
        Map<String, String> querys = new HashMap<>();
        querys.put("number", number);
        querys.put("com", companyCode);
        querys.put("mobile", mobile);
        Map<String, Object> logisticsMessage = logisticsApi.queryLogistics(querys);
        if (logisticsMessage == null){
            throw new Exception(BizEnum.LOGISTICS_ERROR.getMsg());
        }
        return Result.success(logisticsMessage);
    }
}
